#pragma once

#include <ostream>
#include <stdexcept>

#include "article-menu.h"


namespace book
{

class ArticleMenuConvert
{
public:
    class StreamCheckError : public std::logic_error
    {
    public:
        StreamCheckError() : std::logic_error("bad stream") {}
        virtual ~StreamCheckError() {}
    };

    ArticleMenuConvert(const ArticleMenu &menu, std::ostream &out);

    void operator()();

private:
    void convertNestedMenu(const ArticleMenu::Node &node);

private:
    const ArticleMenu &menu_;
    std::ostream &out_;
};

} // namespace book
